package com.application.lucky.request;

import android.text.TextUtils;

import com.application.lucky.request.nav.UrlList;
import com.application.lucky.request.nav.UrlManager;
import com.application.lucky.widget.dialog.TwoButtonDialog;
import com.baselib.libnetwork.net.libnetworkcomponent.BaseResponse;
import com.baselib.libnetwork.net.libnetworkcomponent.HttpCallback;
import com.baselib.libnetwork.net.libnetworkcomponent.PieBaseRequest;
import com.baselib.libnetwork.net.model.ResultResponse;

import java.util.HashMap;
import java.util.Map;

import retrofit2.http.Url;

public class FriendRequest extends PieBaseRequest {
    public void friend_apply(String uid, String apply_type , String message, String message_extern, final LoginRequest.LoginBack<BaseResponse<String>>back){
        Map<String,String>param = new HashMap<>();
        param.put("user_id",uid);
        param.put("message",message);
        param.put("apply_type",apply_type);
        param.put("message_extern",message_extern);
        String url = UrlManager.getUrl(UrlList.friend_apply);

        post(url, param, new CallBackEx<BaseResponse<String>>() {
            @Override
            public void onSuccess(BaseResponse<String> stringBaseResponse) {
                if (back!=null) {
                    back.success(stringBaseResponse);
                }
            }

            @Override
            protected void OnFailureNeedData(int code, BaseResponse<String> stringBaseResponse) {
                if (back!=null) {
                    back.fail(code);
                }
            }

            @Override
            public void onFailed(int code) {

            }

            @Override
            public void onException(ResultResponse response) {
                if (back!=null) {
                    back.fail(response.code());
                }
            }
        });
    }

    public void friend_delete(String uid,final CallBackEx<BaseResponse<String>>back){
        Map<String,String>param = new HashMap<>();
        param.put("user_id",uid);
        param.put("message_extern",uid);
        String url = UrlManager.getUrl(UrlList.friend_sub);

        post(url, param, new CallBackEx<BaseResponse<String>>() {
            @Override
            public void onSuccess(BaseResponse<String> stringBaseResponse) {
                if (back!=null) {
                    back.onSuccess(stringBaseResponse);
                }
            }

            @Override
            protected void OnFailureNeedData(int code, BaseResponse<String> stringBaseResponse) {
                if (back!=null) {
                    back.onFailed(code);
                }
            }

            @Override
            public void onFailed(int code) {

            }

            @Override
            public void onException(ResultResponse response) {
                if (back!=null) {
                    back.onFailed(response.code());
                }
            }
        });
    }

    public void friend_agree(String uid,  String message_extern, final LoginRequest.LoginBack<BaseResponse<String>>back){
        Map<String,String>param = new HashMap<>();
        param.put("user_id",uid);
        param.put("message_extern",message_extern);
        String url = UrlManager.getUrl(UrlList.friend_agree);
        post(url, param, new CallBackEx<BaseResponse<String>>() {
            @Override
            public void onSuccess(BaseResponse<String> stringBaseResponse) {
                if (back!=null) {
                    back.success(stringBaseResponse);
                }
            }

            @Override
            protected void OnFailureNeedData(int code, BaseResponse<String> stringBaseResponse) {
                if (back!=null) {
                    back.fail(code);
                }
            }

            @Override
            public void onFailed(int code) {
                if (back!=null) {
                    back.fail(code);
                }
            }

            @Override
            public void onException(ResultResponse response) {

            }
        });
    }

    public void friend_apply_list(String timem,CallBackEx call){
        String url = UrlManager.getUrl(UrlList.friend_apply_list);
        get(url, "time", timem,call);
    }

    public void friend_list(String timem,CallBackEx call){
        String url = UrlManager.getUrl(UrlList.friend_list);
        get(url, "time", timem,call);

    }
    public void friend_remarks(String user_id,String remarks,CallBackEx call){

        String url = UrlManager.getUrl(UrlList.friend_remarks);
        Map<String,String>param = new HashMap<>();
        param.put("user_id",user_id);
        param.put("remarks",remarks);
        param.put("message_extern","1122");
        get(url,  param,call);

    }

}
